
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<html>
    <head>
        <title>Huy Bee</title>
        <link href="public/css/style.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="public/jc/jquery-1.2.6.min.js"></script>
        <script type="text/javascript">
            function slideSwitch() {
                var $active = $('#baner IMG.active');
                if ($active.length == 0)
                    $active = $('#baner IMG:last');
                var $next = $active.next().length ? $active.next()
                        : $('#baner IMG:first');
                $active.addClass('last-active');
                $next.css({opacity: 0.0})
                        .addClass('active')
                        .animate({opacity: 1.0}, 1000, function() {
                    $active.removeClass('active last-active');
                });
            }
            $(function() {
                setInterval("slideSwitch()", 3000);
            });
        </script>
    </head>
    <body>
        <div id="wrapper">
            <?php
            require_once './model/works.php';
            require_once './model/user.php';
            $keyword = new Works();
            $keyword->table_name = "works";
            ?>
            <?php
            if (!isset($_GET["page"]))
                $page = 1;
            else
                $page = $_GET["page"];

            $total = $keyword->countWords();
            ?>
            <div id="backgroud">
                <div id="baner">
                    <img src="public/image/1321.jpg" alt="" class="active"/>
                    <img src="public/image/skmgfd.jpg" alt="" class="active"/>
                    <img src="public/image/rennekton.jpg" alt="" class="active"/>
                    
                </div>

                <div id="boder"></div>
                <header>
                    <div class="logo">
                        <h1 align="center"><b class="Works">LEAGUE LEGENDS</b></h1>
                        <h2 align="center"><p class="text_td">Mùa Giải GPL 2014</p></h2>
                    </div>
                    <div id="boders"></div>
                    <div id="col_left">
                      
                        <form class="main_menu" method="POST">
                        <p class="main_menu">
                        <h3>Đăng Nhập</h3>
                        <div id="boder_menu"></div>
                        </p>
                        <p>Tài Khoản</p>
                        <input type="text" name="username">
                        <p>Mật Khẩu <strong></strong></p>
                        <input type="password" name="password"></br>
                        <p id="input_st"><input type="submit" name="submit" value="Login" ></p>
                     </form>
                            <?php if (isset($_POST['submit'])): ?>
                        <?php
                            $username = $_POST['username'];
                            $password = $_POST['password'];
                            $Ok = FALSE;
                            $index = -1;
                            for ($i = 0; $i < count($users); $i++) {
                                if ((strcmp($users[$i]['username'], $username) == 0) &&
                                        (strcmp($users[$i]['password'], $password) == 0)) {
                                    $Ok = TRUE;
                                    $index = $i;
                                }
                            }
                            if ($Ok) {
                                header("Location: http://localhost/huy-web2/index.php?uid=".$users[$index]["id"]);
                            } else {
                                echo "Đăng nhập thất bại";
                            }
                            
                            ?>   
                        <?php endif; ?>
                        
                         <?php if (isset($_GET['uid'])): ?>    
                                 <?php if ((int) $_GET['uid'] == 0 && (int) $_GET['uid'] == 1): ?> 
                        <a href ="index.php"><h3 align ="left">Logout</h3></a>
                        <?php else: ?>
                        <a href ="index.php"><h3 align ="left"></h3></a>
                        <?php endif; ?>
                        <?php endif; ?>
                    
                    <?php            
                    ?>             
                   <section>
                        
                        <nav>
                             <p class="main_menu">
                        <h3>Menu</h3>
                        <div id="boder_menu"></div>
                        </p>
                            <ul>
                                <li><a href="index.php">Giới Thiệu</a></li>
                                <li><a href="#">Tin Tức</a></li>
                                <li><a href="#">Giải Đấu</a></li>
                                <li><a href="#">Cộng Đồng</a></li>
                            </ul>
                        </nav>
                        
                    </div>
                    <section>
                        <p class="main_menus">
                        <h3 align="center">Thông Tin</h3>
                        <div id="boder_menus"></div>
                        </p>
                        <div class="fanpage"> 
                            <?php if (!isset($_GET["page"])):
                                ?>

                                <a href="index.php?page=<?php echo $_GET['page'] = 1 ?>">Prew</a>
                            <?php endif; ?>
                            <a href="index.php?page=1">Fist</a>
                            <?php $max_page = 5; ?>
                            <?php for ($i = 1; $i <= $max_page; $i++): ?>
                                <?php if (($_GET["page"] == 1) || ($_GET["page"] == 2) || ($_GET["page"] == 3) || ($_GET["page"] == 4)): ?>            
                                    <?php for ($i = 1; $i <= $max_page; $i++): ?>
                                        <a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a>
                                        <?php if ($_GET["page"] == $i): ?>
                                            <?php $keyword->begin; ?>
                                            <?php $keyword->end = PAGE; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                <?php elseif (($_GET["page"] == $total / PAGE) || ($_GET["page"] == $total / PAGE - 1) || ($_GET["page"] == $total / PAGE - 2) || ($_GET["page"] == $total / PAGE - 3)): ?>        
                                    <?php for ($i = $total / PAGE - $max_page; $i <= $total / PAGE; $i++): ?>
                                        <a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a>
                                        <?php if ($_GET["page"] == $i): ?>
                                            <?php $keyword->begin; ?>
                                            <?php $keyword->end = PAGE; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                <?php else : ?>
                                    <?php for ($i = $_GET["page"] - 3; $i <= $_GET["page"] + 3; $i++): ?>
                                        <a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a>
                                        <?php if ($_GET["page"] == $i): ?>
                                            <?php $keyword->begin; ?>
                                            <?php $keyword->end = PAGE; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                <?php endif; ?> 
                            <?php endfor; ?>
                            <a href="index.php?page=<?php echo $total / PAGE ?>">Last</a>
                            <a href="index.php?page=<?php echo $_GET['page'] + 1 ?>">Next</a>
                            <?php $keywords = $keyword->select($page); ?>
                        </div>

                        <div id="xuat">
                            <table border="1px">
                                <tr class="a">                                   
                                        <tr>
                                            <td>ID</td>
                                            <td>Name</td>
                                            <td>Image</td>
                                            <td>Url</td>
                                            <td>Qption</td> 
                                        </tr>
                                </tr>
                                <?php foreach ($keywords as $bee): ?>
                                    <tr class="b">
                                        <td><?php echo $bee['id']; ?></td>
                                        <td><?php echo $bee['name']; ?></td>
                                        <td><img src="<?php echo$bee['image'] ?>" with="100px" height="100px"></td>
                                        <td><a href='<?php echo $bee['url']; ?>'><?php echo $bee['url']; ?></td>
                                        <td class="dk">
                                            <img src="public/image/UniversalEditButton3-22230410.png" width="15px" height="15px"><a href="edit.php?id=<?php echo $bee['id']; ?>">Edit</a>
                                            <img src="public/image/Zoom_in.png" width="15px" height="15px"><a href="edit.php">View</a>
                                            <img src="public/image/2629515-366279-delete-metallic-3d-vibrant-round-icon.jpg" width="15px" height="15px"><a href="edit.php">Deleted</a>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </table>
                        </div>
                    </section>
                    <div class="clear"></div>
                    <div id="top"><a href="index.php">Lên Top</a></div>
                </header>
                <div class="clear"></div>
                <div id="boder"></div>
                <footer>
                    <p class="colleft">
                    <table class="o">
                        
                        <tr>
                            <td>1.Lee-Ryn</td><td></td></tr>
                        <tr><td>2.Huy-Bee</td><td></td></tr>
                        

                    </table>
                    </p>
                </footer>
            </div>
        </div>
    </body>
</html>
